package org.jeecg.modules.job.rms.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.job.rms.entity.RmsCompany;
import org.jeecg.modules.job.rms.mapper.RmsCompanyMapper;
import org.jeecg.modules.job.rms.service.IRmsCompanyService;
import org.jeecg.modules.job.ums.entity.UmsMemberRole;
import org.jeecg.modules.job.ums.service.IUmsMemberRoleService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @Description: 公司列表
 * @Author: jeecg-boot
 * @Date:   2022-12-18
 * @Version: V1.0
 */
@Service
public class RmsCompanyServiceImpl extends ServiceImpl<RmsCompanyMapper, RmsCompany> implements IRmsCompanyService {

    @Resource
    private RmsCompanyMapper rmsCompanyMapper;
    @Resource
    private IUmsMemberRoleService memberRoleService;


    @Override
    public boolean updateStatus(RmsCompany company) {
        company.setAuthDate(new Date());
        return this.updateById(company);
    }

    @Override
    public IPage<RmsCompany> getCompanyPageList(Page<RmsCompany> page, RmsCompany params) {
        return rmsCompanyMapper.getCompanyPageList(page,params);
    }

    @Override
    public IPage getCompanyPageMapList(Page<RmsCompany> page, RmsCompany params) {
        return rmsCompanyMapper.getCompanyPageMapList(page,params);
    }

    @Transactional
    @Override
    public boolean updateCompany(RmsCompany param) {
        UmsMemberRole role=new UmsMemberRole();
        if (StringUtils.isNotEmpty(param.getId())){
            this.updateById(param);
        }else{
            this.save(param);
        }
        role.setCompanyId(param.getId());
        role.setMemberId(param.getMemberId());
        role.setPostName(param.getPostName());
        return memberRoleService.saveOrUpdateRole(role);
    }
}
